#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
#define ldb long double
#define ll long long
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second
#define nextLine() {int c = 0; while ((c = getchar()) != 10 && c != EOF); }
const ldb pi = fabsl(atan2l(0.0, -1.0));
const ldb eps = 1e-9;
const int inf = 1 << 28;

vector <int> a;
int n, x;
void load()
{
	cin >> n >> x;
	a.resize(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
}

void intersect(int &c, int &d, int a, int b)
{
	c = max(c, a);
	d = min(d, b);
}

int solve(int x)
{
	if (x < 2) return -1;
	int c = 2, d = x;
	int cnt = 0;
	for (int i = 0; i < a.size() && c < d; i++)
	{
		int p = a[i];
		bool ok = true;
		for (int j = 2; ok && j * j <= p; j++)
		{
			if (p % j == 0)
			{
				vector <int> :: iterator it = lower_bound(a.begin(), a.begin() + i, j);
				if (it != a.end() && *it == j)
				{
					ok = false;
					break;
				}
				it = lower_bound(a.begin(), a.begin() + i, p/j);
				if (it != a.end() && *it == p/j)
				{
					ok = false;
					break;
				}
			}
		}
		if (!ok) continue;
		cnt++;
		intersect(c, d, (x / a[i] + (x % a[i] != 0)) * a[i] - a[i] + 1, (x / a[i] + (x % a[i] != 0)) * a[i]);
	}
	if (c == d) return cnt;
	else return inf;
}

inline int random()
{
	return (rand() << 16) | rand();
}

void solve()
{
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	int res = solve(x);
	res = max(res, solve(2));
	ll _x = 1;
	for (int i = 0; i < a.size(); i++)
	{
		_x = _x / __gcd((ll)a[i], _x) * a[i];
		if (_x > x) break;
		for (int t = -300; t < 300; t++)
		{
			if (_x + t > x) break;
			res = max(res, solve(_x + t));
		}
	}
	res = max(res, solve(x/2));
	res = max(res, solve(min(x, x/2 + 1)));
	res = max(res, solve(x/2 - 1));
	if (a.size())
		res = max(res, solve(x - (x % a[0])));
	if (res == inf) cout << -1;
	else cout << res;
}

#define file "e"

int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
  	#endif
  	load();
  	solve();
  	return 0;
}
